{extend name="../../admin/view/main"}
{block name="button"}
<!--{if auth("merge")}-->
<button  data-action='{:url("merge")}' data-rule="id#{key}"  class='layui-btn layui-btn-sm layui-btn-primary'>计划整合</button>
<!--{/if}-->
{/block}
{block name="content"}
<div class="think-box-shadow">
    {include file='/control/plan_merge/index_search'}
    <table class="layui-table margin-top-10" lay-skin="line">
        {notempty name='list'}
        <thead>
        <tr>
            <th class='text-center nowrap'>
                <button type="button" data-reload class="layui-btn layui-btn-xs">刷 新</button>
            </th>
            <th class='text-center nowrap'>合并ID</th>
            <th class='text-center nowrap'>标题</th>
            <th class='text-center nowrap'>合并人账号（昵称）</th>
            <th class='text-center nowrap'>当前审批人（昵称）</th>
            <th class='text-center nowrap'>审批状态</th>
            <th class='text-center nowrap'>合并时间</th>
            <th class='text-center nowrap'>计划整合时间</th>
            <th class='text-right'></th>
        </tr>
        </thead>
        {/notempty}
        <tbody>
        {foreach $list as $vo}
        <tr data-dbclick>
            <td class='list-table-check-td think-checkbox'><input class="list-check-box" value='{$vo.id}' type='checkbox'></td>
            <td class='text-center nowrap'>
                <div class="inline-block">{$vo.id|default='--'}<br></div>
            </td>
            <td class='text-center nowrap'>
                <div class="inline-block">{$vo.title|default='--'}<br></div>
            </td>
            <td class='text-center nowrap'>
                <div class="inline-block">{$vo.admin_name|default='--'}（{$vo.admin_nickname|default='--'}）<br></div>
            </td>
            <td class='text-center nowrap'>
                <div class="inline-block">{$vo.below_admin_name|default='--'}（{$vo.below_nickname|default='--'}）<br></div>
            </td>
            <td class='text-center nowrap'>
                {eq name='vo.status' value='0'}<span class="layui-badge" style="background: #FFB800;color: #fff">待审核</span>{/eq}{eq name='vo.status' value='1'}<span class="layui-badge layui-bg-green">已通过</span>{/eq}{eq name='vo.status' value='-1'}<span class="layui-badge">已拒绝</span>{/eq}<br>
            </td>
            <td class='text-center nowrap'>
                <div class="inline-block">{$vo.merge_time|date='Y-m-d H:i:s'}<br></div>
            </td>
            <td class='text-center nowrap'>
                {if $vo.integration_time}
                <div class="inline-block">{$vo.integration_time|date='Y-m-d H:i:s'}<br></div>
                {else /}
                <div class="inline-block" style="color:red;">待整合数据<br></div>
                {/if}
            </td>

            <td class='text-center nowrap'>
                <!-- {if auth("detail")}-->
                <a data-title="详 情" data-dbclick class="layui-btn layui-btn-sm" data-width="80%" data-modal='{:url("detail")}?id={$vo.id}'>详 情</a>
                <!--{/if}-->
                {if $vo.status eq -1 and $vo.plan_status eq 2}
                    <!--{if auth("remove")}-->
                    <a class="layui-btn layui-btn-sm layui-btn-danger" data-confirm="确定要删除数据吗?" data-action="{:url('remove')}" data-value="id#{$vo.id}">删 除</a>
                    <!--{/if}-->
                {/if}
                {if $vo.status eq 0 and $vo.plan_status eq 2}
                <!--{if auth("remove")}-->
                <a class="layui-btn layui-btn-sm layui-btn-danger" data-confirm="确定要删除数据吗?" data-action="{:url('remove')}" data-value="id#{$vo.id}">删 除</a>
                <!--{/if}-->
                {/if}
                <!-- {if auth("to_examine") and  $vo.status eq 0 and $authorize eq $vo.plan_status and $authorize < 4}-->
                <a class="layui-btn layui-btn-sm layui-btn-warm" data-width="40%" data-modal='{:url("to_examine")}?id={$vo.id}'>审 批</a>
                <!--{/if}-->
                <!--{if auth("refusal") and $vo.status eq 0 and $authorize eq $vo.plan_status and !$vo.integration_id}-->
                <a class="layui-btn layui-btn-sm layui-btn-danger" onclick="refusalCause('{$vo.id}');">拒 绝</a>
                <!--{/if}-->
            </td>
            <td class='text-left nowrap padding-0 relative'></td>
        </tr>
        {/foreach}
        </tbody>
    </table>

    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}

</div>
<script>
    form.render()
    function refusalCause(ids) {
        var remarkReason = "";
        layer.prompt({
            formType: 0,
            value: '',
            title: '拒绝后需从头审批，请谨慎操作',
            btn: ['确定', '取消'], //按钮，
            btnAlign: 'c'
        }, function (value, index) {
            remarkReason = value;
            layer.close(index);
            $.ajax({
                type: 'POST',
                url: "{:url('refusal')}",
                data: {
                    id: ids,
                    refusal_cause: remarkReason
                },
                dataType: "json",
                success: function (data) {
                    console.log(data)
                    if (data.code == 1) {
                        layer.msg(data.info, {icon: 1}, function () {
                            console.log(index)
                            parent.location.reload();
                        });
                    }
                }
            });
        }, function (value, index) {

        });
    }
</script>
{/block}
